require.config({
    paths: {
        'jquery': ['http://cdn.bootcss.com/jquery/2.2.4/jquery.min', '/js/lib/jquery.min'],
        'doT': '/js/lib/doT.min',
        'bootstrap': '/js/lib/bootstrap.min',
        'datetimepicker': '/js/lib/bootstrap-datetimepicker.min',
        'select2': '/js/lib/select2.min'
    },
    shim: {
        'bootstrap': ['jquery']
    }
});

require(['jquery', 'doT', 'common', 'bootstrap'], function($, doT, common) {
    $(function() {
        $(document).on('click', '.togglePanel', function(e) {
            $(e.currentTarget).next('.panel-body').slideToggle();
        });

        function refreshManagerList() {
            var managerTmpl = doT.template($('#managerTmpl').text());
            var managers = [{ name: 'zhangsan' }, { name: 'lisi' }];
            $('#managerList').html(managerTmpl(managers));

        }

        refreshManagerList();

        function refreshSchoolList() {
            var schoolTmpl = doT.template($('#schoolTmpl').text());
            var schools = [{ name: '星海学院', tangzhus: [{ name: 'zhangsan', id: 1 }, { name: 'lisi', id: 2 }, { name: 'wangwu', id: 3 }] }, { name: '华南理工大学', tangzhus: [{ name: 'zhangsan', id: 1 }, { name: 'lisi', id: 2 }, { name: 'wangwu', id: 3 }] }];
            $('#schoolList').html(schoolTmpl(schools));
        }

        refreshSchoolList();

        function upgratePromt() {
            var upgrateTmpl = doT.template($('#upgrateTmpl').text());
            var tangzhu = { name: 'zhangsan', id: 1 };
            $('#upgrateModal').html(upgrateTmpl(tangzhu));
            $('#upgrateModal').modal('show');
        }

        $(document).on('click','.upgrateTangzhu',function (e) {
            upgratePromt($(e.target).attr('data-id'));
        });
    });
});
